package com.java.base.exercise.leetcode;

import java.util.Arrays;

/**
 * @Author RenPu
 * @Date 2024/2/20 22:00
 * @Version 1.0
 * @Description:
 **/
public class Exercise02 {


    public static void main(String[] args) {

        int [] nums= {1,2,7,4,2,3,2};

        int val=2;
        Integer integer = dealWitahData(nums, val);

        System.out.println(integer);


    }

    private static Integer dealWitahData(int[] nums, int val) {

        int len=nums.length;

        int left=0;

        for (int right= 0; right <len ;right ++) {
               if(nums[right]!=val){
                   nums[right]=nums[left];
                   left++;
               }
        }
        return left;
    }


}
